package cate.game.activity.lostdreamland.msg;

import cate.game.GameBody;
import cate.game.activity.lostdreamland.LostDreamlandActivity;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBLostDreamland;
import easy.java.dev.note.NoteField;
import easy.java.practice.errorcode.EcResult;

@ClientMsg(title = "迷失幻境挑战的 の 请求")
public class LostDreamlandChallengeReq implements MsgInput {
    @NoteField(value = "活动ID")
    public int funcId;

    @NoteField(value = "层数")
    public int level;

    @Override
    public MsgConfig conf() {
        return MsgIdBLostDreamland.CHALLENGE_REQ;
    }

    @Override
    public void execute(GameBody game, ClientContext cc) {
        LostDreamlandActivity single = cc.getRole().getActivity().getEnableActivitySingle(funcId);
        if (single == null) {
            cc.getRole().getGame().notice.message(cc.getRole(), "活动未开启");
            return;
        }
        EcResult<Void> r = single.challenge(level);
        if (!r.ok()) {
            game.notice.message(cc.getRole(), r.message);
        }
    }
}
